package com.ibm.cloud.banking.trans.customer;

import com.ibm.cloud.banking.facade.customer.ICustomerCommandFacade;
import com.ibm.cloud.banking.facade.customer.dto.CustomerCertificateDTO;
import com.ibm.cloud.banking.prod.dto.ProductCheckDTO;
import com.ibm.cloud.banking.trans.account.dto.Req111225;
import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;

@Service
public class Trans111114 extends RouteBuilder {

    @Resource
    ICustomerCommandFacade customerCommandFacade;


    String PCS_CODE = "T21";
    String ROUTE_URI = "direct:T21";
    String ROUTE_DESC = "客户信息查询交易";
    String ROUTE_ID = "PCS-FLOW-T21";

    String GETTING_CUSTOMER_INFO = "direct:500";

    @Override
    public void configure() throws Exception {
        from(ROUTE_URI)
                .routeDescription(ROUTE_DESC)
                .routeId(ROUTE_ID)
                .log("开始执行客户查询交易。")
                .to(GETTING_CUSTOMER_INFO)
                .log("客户查询交易执行结束");

        from(GETTING_CUSTOMER_INFO)
                .process(exchange -> {
                    Map<String, Object> requestMsg = (LinkedHashMap<String, Object>)exchange.getIn().getBody();

                    CustomerCertificateDTO certificateDTO = new CustomerCertificateDTO();
                    certificateDTO.setName((String)requestMsg.get("name"));
                    certificateDTO.setIdType((String)requestMsg.get("idType"));
                    certificateDTO.setIdNo((String)requestMsg.get("idNo"));

                    exchange.getIn().setBody(certificateDTO, CustomerCertificateDTO.class);
                })
                .bean(customerCommandFacade, "getCustomer").log("查询客户信息");

    }
}
